#include "SQLSubPartition.h"
#include "../visitor/SQLASTVisitor.h"
#include "SQLName.h"
#include "SQLPartitionValue.h"
#include "SQLExpr.h"

SQLName_ptr SQLSubPartition::getName()
{
  return name;
}

void SQLSubPartition::setName(SQLName_ptr name)
{
  if (name != nullptr)
  {
    name->setParent(SharedObject(SQLSubPartition));
  }
  this->name = name;
}

SQLPartitionValue_ptr SQLSubPartition::getValues()
{
  return values;
}

void SQLSubPartition::setValues(SQLPartitionValue_ptr values)
{
  if (values != nullptr)
  {
    SQLObjectImpl::setParent(SharedObject(SQLSubPartition));
  }
  this->values = values;
}

SQLName_ptr SQLSubPartition::getTableSpace()
{
  return tableSpace;
}

void SQLSubPartition::setTableSpace(SQLName_ptr tableSpace)
{
  if (tableSpace != nullptr)
  {
    tableSpace->setParent(SharedObject(SQLSubPartition));
  }
  this->tableSpace = tableSpace;
}

SQLExpr_ptr SQLSubPartition::getDataDirectory()
{
  return dataDirectory;
}

void SQLSubPartition::setDataDirectory(SQLExpr_ptr dataDirectory)
{
  this->dataDirectory = dataDirectory;
}

SQLExpr_ptr SQLSubPartition::getIndexDirectory()
{
  return indexDirectory;
}

void SQLSubPartition::setIndexDirectory(SQLExpr_ptr indexDirectory)
{
  this->indexDirectory = indexDirectory;
}

SQLExpr_ptr SQLSubPartition::getMaxRows()
{
  return maxRows;
}

void SQLSubPartition::setMaxRows(SQLExpr_ptr maxRows)
{
  this->maxRows = maxRows;
}

SQLExpr_ptr SQLSubPartition::getMinRows()
{
  return minRows;
}

void SQLSubPartition::setMinRows(SQLExpr_ptr minRows)
{
  this->minRows = minRows;
}

SQLExpr_ptr SQLSubPartition::getEngine()
{
  return engine;
}

void SQLSubPartition::setEngine(SQLExpr_ptr engine)
{
  this->engine = engine;
}

SQLExpr_ptr SQLSubPartition::getComment()
{
  return comment;
}

void SQLSubPartition::setComment(SQLExpr_ptr comment)
{
  this->comment = comment;
}

// @Override
void SQLSubPartition::accept0(SQLASTVisitor_ptr visitor)
{
  if (visitor->visit(SharedObject(SQLSubPartition)))
  {
    acceptChild(visitor, name);
    acceptChild(visitor, tableSpace);
    acceptChild(visitor, values);
  }
  visitor->endVisit(SharedObject(SQLSubPartition));
}

SQLObject_ptr SQLSubPartition::clone()
{
  SQLObject_ptr clone_tmp = SQLSubPartition_ptr(new SQLSubPartition());
  SQLSubPartition_ptr x = std::dynamic_pointer_cast<SQLSubPartition>(clone_tmp);
  // SQLSubPartition* x = new SQLSubPartition();

  if (name != nullptr)
  {
    x->setName(std::dynamic_pointer_cast<SQLName>(name->clone()));
  }

  if (values != nullptr)
  {
    x->setValues(std::dynamic_pointer_cast<SQLPartitionValue>(values->clone()));
  }

  if (tableSpace != nullptr)
  {
    x->setTableSpace(std::dynamic_pointer_cast<SQLName>(tableSpace->clone()));
  }

  return x;
}
